// 1.设置标识
const KEY = "manage_taken_2006";

//用户信息

const USER_KEY = "userInfo";

//设置token
export function setToken(value) {
  window.localStorage.setItem(KEY, value);
}

// 获取token
export function getToken() {
  var tokenStr = window.localStorage.getItem(KEY);
  if (!tokenStr || tokenStr === "undefined") {
    return null;
  } else {
    return tokenStr;
  }
}
// 删除token

export function removeToken() {
  window.localStorage.removeItem(KEY);
}

//保存用户信息

export function saveUserInfo(userInfo) {
  if (userInfo) {
    var userInfoStr = JSON.stringify(userInfo);
    window.localStorage.setItem(USER_KEY, userInfoStr);
  }
}

//获取用户信息
export function getUserInfo(userInfo) {
  var userInfoStr = window.localStorage.getItem(USER_KEY);
  if (!userInfoStr || userInfoStr === "undefined") {
    return null;
  } else {
    var userInfo = JSON.parse(userInfoStr);
    return userInfo;
  }
}

//清除用户信息

export function removeUserInfo() {
  window.localStorage.removeItem(USER_KEY);
}

// 清空所有缓存

export function clearUserCache() {
  removeToken();
  removeUserInfo();
}

